<template>
  <div class="bigBox">
    <el-card>
      <div style="display: flex;">
        <div style="width: 50%;">
          <div class="topBox">
            <div v-for="(item, index) in topItems" :key="'top' + index" class="topBoxCon"
              :class="{'active': selectedTop === index}" @click="selectTop(index)">
              {{ item }}
            </div>
          </div>
          <div class="middleBox">
            <div v-for="(item, index) in middleItems" :key="'middle' + index" class="middleBoxCon"
              :class="{'active': selectedMiddle === index}" @click="selectMiddle(index)">
              {{ item }}
            </div>
          </div>
          <div style="display: flex;align-items: center;margin-top: 15px;">
            <div style="margin-right: 10px;">产品名称:</div>
            <el-input style="width: 425px;"></el-input>
          </div>
        </div>
        <div class="rightBox">
          <div class="title">
            业务单据数量
          </div>
          <div class="right">
            <div class="imgBox" style="background-color: #E6E6FA;">
              <img style="width:30px;height:30px;text-align: center;" src="@/assets/images/djsl.png" alt="" />
            </div>
            <div>100</div>
          </div>
        </div>
        <div class="rightBox">
          <div class="title">
            产品品类
          </div>
          <div class="right">
            <div class="imgBox" style="background-color: #D3D3D3;">
              <img style="width:30px;height:30px;text-align: center;" src="@/assets/images/cppl.png" alt="" />
            </div>
            <div>100</div>
          </div>
        </div>
        <div class="rightBox">
          <div class="title">
            出入库数量
          </div>
          <div class="right">
            <div class="imgBox" style="background-color: #a8dbd0;">
              <img style="width:30px;height:30px;text-align: center;" src="@/assets/images/crksl.png" alt="" />
            </div>
            <div>100</div>
          </div>
        </div>
      </div>
    </el-card>
    <el-row>
      <el-col :span="24">
        <div class="areaChart">
          <totalChart />
        </div>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <div class="areaChart">
          <totalTable />
        </div>
      </el-col>
    </el-row>
  </div>
</template>


<script>
  import totalChart from './other/totalChart.vue'
  import totalTable from './other/totalTable.vue'

  export default {
    data() {
      return {
        // 当前选中的 topBox 和 middleBox 索引
        selectedTop: 0,
        selectedMiddle: 0,
        // topBox 和 middleBox 的数据
        topItems: ['销售出库', '采购入库', '其他出库', '其他入库'],
        middleItems: ['今天', '本周', '本月', '今年'],
      }
    },
    components: {
      totalChart,
      totalTable
    },
    methods: {
      // 选择 topBox 时更新选中项
      selectTop(index) {
        this.selectedTop = index
      },
      // 选择 middleBox 时更新选中项
      selectMiddle(index) {
        this.selectedMiddle = index
      }
    }
  }
</script>


<style scoped lang="scss">
  .bigBox {
    width: 100%;
  }

  .el-row {
    margin-top: 10px;
  }

  .areaChart {
    border: 1px solid #e1e1e1;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 5px 5px 10px 0px rgba(0, 0, 0, 0.1);
  }

  .topBox {
    width: 600px;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .topBoxCon {
      width: 120px;
      height: 40px;
      border-radius: 5px;
      text-align: center;
      border: 1px solid #dcdfe6;
      line-height: 40px;
      cursor: pointer;
      transition: background-color 0.3s, color 0.3s;
    }

    .topBoxCon.active {
      background-color: #409EFF;
      color: white;
      border: none;
    }
  }

  .middleBox {
    display: flex;
    width: 400px;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;

    .middleBoxCon {
      border: 1px solid #dcdfe6;
      width: 80px;
      height: 40px;
      border-radius: 5px;
      text-align: center;
      line-height: 40px;
      cursor: pointer;
      transition: background-color 0.3s, color 0.3s;
    }

    .middleBoxCon.active {
      background-color: #409EFF;
      color: white;
      border: none;
    }
  }

  .title:before {
    content: "";
    background: #8cc5ff;
    display: inline-block;
    width: 6px;
    height: 20px;
    margin-right: 10px;
  }

  .rightBox {
    margin-bottom: 10px;
    padding: 0 10px;
    height: 150px;
    width: 300px;
    border-radius: 10px;
    border: 1px solid #e1e1e1;
    box-shadow: 5px 5px 10px 0px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
    margin-left: 20px;

    .title {
      display: flex;
      align-items: center;
      color: #333333;
      font-weight: bold;
      padding: 10px 0px;
      font-size: 18px;
    }

    .right {
      font-size: 30px;
      color: #409EFF;
      font-weight: bold;
      line-height: 100px;
      display: flex;
      align-items: center;
      justify-content: space-around;
    }

    .imgBox {
      width: 50px;
      height: 50px;
      border-radius: 5px;
      background-color: #eef7ff;
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
</style>
